﻿<!-- 工作量-初始化,生成上课信息 -->
<template>
    <div>
        <!-- 添加按钮 -->
        <div class="btn-add">
            <button type="button" class="btn btn-info btn-lg" @click="addsk()"><i class="iconfont icon-xinjian ft12 mr5"></i>1-预生成学期明细</button>
            <button type="button" class="btn btn-success btn-lg" @click="zhsj()"><i class="iconfont icon-chenggong ft12 mr5"></i>转换时间</button>
        </div>
        <!-- 按条件选择 -->



        <div class="tab-filter-type ">

            <div class="col-xs-2 padding20">
                <div class="input-group" style="margin-bottom:10PX;">
                    <div class="input-group-btn">
                        <button type="button" style="height: 34px;min-width:80PX" class="btn btn-primary  dropdown-toggle">学期</button>
                    </div>
                    <base-xq :pzoption="query.xq" isnow></base-xq>

                </div>
            </div>
            <div class="col-xs-2 padding20">
                <div class="input-group" style="margin-bottom:10PX;">
                    <div class="input-group-btn">
                        <button type="button" style="height: 34px;min-width:80PX" class="btn btn-primary  dropdown-toggle">确认状态</button>
                    </div>
                    <el-select placeholder="确认状态" size="mini" v-model="query.qrzt" class="form-control filter" style="height: 34px;padding:0px">
                        <el-option label="未生成" value="0"></el-option>
                        <el-option label="已生成" value="1"></el-option>

                    </el-select>

                </div>
            </div>
        </div>

        <div class="default-tab ft14  hover-btn" style="overflow-x: inherit;padding:20PX;padding-top:10px">


            <base-table :pzoption="tableop" @selection-change="handleSelectionChange">
            </base-table>
        </div>
        <!-- 表格 -->



    </div>
</template>

<script>
    module.exports = {
        props: ['pdata'],
        components: {
            'base-table': httpVueLoader('/ViewV5/Base/Vue/Table.vue'),
            'base-xq': httpVueLoader('/ViewV5/AppPage/QJJW/component/conxq.vue')
        },
        data: function () {
            return {
                query: {
                    qrzt: "0",
                    xq: { value: "" },
                },
                tableop: {
                    title: "教学任务信息",
                    issel: true,
                    iscz: false,
                    height: 500,
                    isxh: true,
                    loading: true,
                    dataset: [],
                    multipleSelection: [],
                    collist: [
                        { colid: "kcxbmc", colname: "课程系部名称", isshow: true, istip: true },
                        { colid: "kcmc", colname: "课程名称", isshow: true, istip: true },
                        { colid: "kcdm", colname: "课程代码", isshow: true, istip: true },
                        { colid: "jsmc", colname: "上课教师", isshow: true, istip: true },
                        { colid: "hbbj", colname: "上课班级", isshow: true, istip: true },
                        { colid: "hb", colname: "上课班级代码", isshow: true, istip: true }



                    ]
                }
            }
        },
        methods: {
            handleSelectionChange(val) {
                this.tableop.multipleSelection = val;
            },
            querydata: function () {
                var pro = this;
                pro.tableop.loading = true;
                $.getJSON('/API/VIEWAPI.ashx?Action=GZL_GETDSCJXRW', { P1: pro.query.xq.value, P2: pro.query.qrzt }, function (resultData) {
                    if (!resultData.ErrorMsg) {
                        pro.tableop.dataset = resultData.Result;
                        pro.tableop.loading = false;

                    }
                })

            },
            zhsj: function () {

                var pro = this;
                $.getJSON('/API/VIEWAPI.ashx?Action=GZL_SJZHGZL', { P1: pro.query.xq.value}, function (resultData) {
                    if (!resultData.ErrorMsg) {
                        pro.$notify({
                            title: '成功',
                            message: '操作成功',
                            type: 'success'
                        });
                    }
                })
                
            },
            addsk: function () {
                var pro = this;
                var kcdm = [];
                var hb = [];

                for (var i = 0; i < this.tableop.multipleSelection.length; i++) {
                    kcdm.push(this.tableop.multipleSelection[i].kcdm);
                    hb.push(this.tableop.multipleSelection[i].hb);
                }
                if (kcdm.length == 0) {
                    this.$notify.error({
                        title: '错误',
                        message: '至少需要选择一条数据才能操作'
                    });
                    return;
                }
                $.getJSON('/API/VIEWAPI.ashx?Action=GZL_SETSKJHGZL', { P1: pro.query.xq.value, kcdm: kcdm.join("$"), hb: hb.join("$") }, function (resultData) {
                    if (!resultData.ErrorMsg) {
                        pro.$notify({
                            title: '成功',
                            message: '操作成功',
                            type: 'success'
                        });
                        pro.querydata();

                    }
                })

            },
            InitWigetData: function () {
                this.querydata();
            },
        },
        watch: {
            'query': { //深度监听，可监听到对象、数组的变化
                handler(newV, oldV) {
                    var chi = this;
                    if (newV) {
                        chi.querydata();
                    }
                },
                deep: true
            }
        },
        mounted: function () {
            var pro = this;
            pro.$nextTick(function () {
                pro.InitWigetData();
            })

        }
    };
</script>